package com.zhuss.controller.food;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.zhuss.bean.bo.core.CreateScheduleBo;
import com.zhuss.bean.bo.food.product.DetailProductBo;
import com.zhuss.bean.bo.food.product.SearchProductBo;
import com.zhuss.bean.bo.food.product.box.wechat.ListBoxBo;
import com.zhuss.bean.bo.food.product.stirfry.wechat.ListStirfryBo;
import com.zhuss.bean.bo.food.product.stirfry.wechat.ListStirfryFetchTimeBo;
import com.zhuss.bean.bo.food.product.takeout.wechat.ListTakeoutBo;
import com.zhuss.bean.bo.food.product.takeout.wechat.ListTakeoutStartTimeBo;
import com.zhuss.bean.bo.food.product.week.wechat.ListFloorBo;
import com.zhuss.bean.bo.food.product.week.wechat.ListFloorMenuBo;
import com.zhuss.bean.bo.food.product.week.wechat.ListWeekDayBo;
import com.zhuss.bean.bo.food.product.week.wechat.ListWeekMenuBo;
import com.zhuss.common.AbstractBo;
import com.zhuss.common.BaseController;
import com.zhuss.common.ReadService;
import com.zhuss.common.SelectVo;
import com.zhuss.core.processor.ScheduleCreate;
import com.zhuss.enums.DiningType;
import com.zhuss.enums.DrinkType;
import com.zhuss.enums.EnumUtil;
import com.zhuss.enums.FoodTime;
import com.zhuss.enums.HavingStandard;
import com.zhuss.exception.WpsException;
import com.zhuss.food.product.ProductReadServiceExt;
import com.zhuss.food.product.ProductReadServiceWechat;


/**
 * 商品查询 controller
 * @Author zhushanshuo
   @Date 2020/03/12 16:01
 *
 */
  
 
@RestController
@RequestMapping("/product")
public class ProductReadController extends BaseController {
	
	@Autowired
	@Qualifier("productReadService")
	private ReadService<Object, Object> productReadService;
	
	@Autowired
	@Qualifier("productReadServiceExt")
	private ProductReadServiceExt productReadServiceExt;
	
	@Autowired
	@Qualifier("productReadServiceWechat")
	private ProductReadServiceWechat productReadServiceWechat;
	
	@Autowired
	private ScheduleCreate scheduleCreate;
	
	/**
	 * 点炒服务 堂吃、外带
	 * @param bo
	 * @return
	 */
	@ResponseBody
	@RequestMapping("/listDiningType")
	public Object listDiningType(@RequestBody AbstractBo bo) {
		List<SelectVo> result = new ArrayList<SelectVo>();
		result = EnumUtil.listSelect(DiningType.class);
		return result;
	}
	
	/**
	 * 获取点炒服务取餐区间
	 * @param bo
	 * @return
	 */
	@ResponseBody
    @RequestMapping("/listStirfryFetchTime")
    public Object listStirfryFetchTime(@RequestBody ListStirfryFetchTimeBo bo) {
		scheduleCreate.process(new CreateScheduleBo());
    	Object result = productReadServiceWechat.listStirfryFetchTime(bo);
    	return result;	
	}
	
	/**
	 * 获取晚餐预定
	 * @param bo
	 * @return
	 * @throws WpsException
	 */
	@ResponseBody
    @RequestMapping("/listDinner")
    public Object listDinner(@RequestBody ListStirfryBo bo) throws WpsException {
    	
		Object result = productReadServiceWechat.listDinner(bo);
    	return result;
    }
	
	/**
	 * 获取点炒服务
	 * @param bo
	 * @return
	 * @throws WpsException
	 */
	@ResponseBody
	@RequestMapping("/listStirfry")
	public Object listStirfry(@RequestBody ListStirfryBo bo) throws WpsException {
		
		Object result = productReadServiceWechat.listStirfry(bo);
		return result;
	}
	
	/**
	 * 获取公务接待
	 * @param bo
	 * @return
	 * @throws WpsException
	 */
	@ResponseBody
    @RequestMapping("/listBox")
    public Object listBox(@RequestBody ListBoxBo bo) throws WpsException {
    	
		Object result = productReadServiceWechat.listBox(bo);
    	return result;
    }
	
	/**
	 * 公务接待用餐类型
	 * @param bo
	 * @return
	 */
	@ResponseBody
	@RequestMapping("/listBoxFoodTime")
	public Object listBoxFoodTime(@RequestBody AbstractBo bo) {
		List<SelectVo> result = new ArrayList<SelectVo>();
		result = EnumUtil.listSelect(FoodTime.class);
		for (int i = result.size() - 1; i >= 0; i--) {
			SelectVo sv = result.get(i);
			if (FoodTime.早餐.sameKey(sv.getId())) {
				result.remove(sv);
			}
			if (FoodTime.特色餐.sameKey(sv.getId())) {
				result.remove(sv);
			}
		}
		return result;
	}
	
	/**
	 * 公务接待 用餐标准
	 * @param bo
	 * @return
	 */
	@ResponseBody
	@RequestMapping("/listBoxHavingStandard")
	public Object listBoxHavingStandard(@RequestBody AbstractBo bo) {
		List<SelectVo> result = new ArrayList<SelectVo>();
		result = EnumUtil.listSelect(HavingStandard.class);
		return result;
	}
	
	/**
	 * 获取 饮品类型
	 * @param bo
	 * @return
	 */
	@ResponseBody
	@RequestMapping("/listBoxDrinkType")
	public Object listBoxDrinkType(@RequestBody AbstractBo bo) {
		List<SelectVo> result = new ArrayList<SelectVo>();
		result = EnumUtil.listSelect(DrinkType.class);
		return result;
	}
	
	/**
	 * 获取外卖打包
	 * @param bo
	 * @return
	 * @throws WpsException
	 */
	@ResponseBody
    @RequestMapping("/listTakeout")
    public Object listTakeout(@RequestBody ListTakeoutBo bo) throws WpsException {
    	
		Object result = productReadServiceWechat.listTakeout(bo);
    	return result;
    }
	
	/**
	 * 获取外卖时间区间
	 * @param bo
	 * @return
	 * @throws WpsException
	 */
	@ResponseBody
    @RequestMapping("/listTakeoutStartTime")
    public Object listTakeoutStartTime(@RequestBody ListTakeoutStartTimeBo bo) throws WpsException {
    	
		Object result = productReadServiceWechat.listTakeoutStartTime(bo);
    	return result;
    }
	
	/**
	 * 获取每日区间
	 * @param bo
	 * @return
	 * @throws WpsException
	 */
	@ResponseBody
    @RequestMapping("/listFloor")
    public Object listFloor(@RequestBody ListFloorBo bo) throws WpsException {
    	
		Object result = productReadServiceWechat.listFloor(bo);
    	return result;
    }
	
	/**
	 * 获取每日区间菜单
	 * @param bo
	 * @return
	 * @throws WpsException
	 */
	@ResponseBody
    @RequestMapping("/listFloorMenu")
    public Object listFloorMenu(@RequestBody ListFloorMenuBo bo) throws WpsException {
    	
		Object result = productReadServiceWechat.listFloorMenu(bo);
    	return result;
    }
	
	/**
	 * 获取每周区间
	 * @param bo
	 * @return
	 * @throws WpsException
	 */
	@ResponseBody
    @RequestMapping("/listWeekDay")
    public Object listWeekDay(@RequestBody ListWeekDayBo bo) throws WpsException {
    	
		Object result = productReadServiceWechat.listWeekDay(bo);
    	return result;
    }
	
	/**
	 * 获取每周区间菜单
	 * @param bo
	 * @return
	 * @throws WpsException
	 */
	@ResponseBody
    @RequestMapping("/listWeekMenu")
    public Object listWeekMenu(@RequestBody ListWeekMenuBo bo) throws WpsException {
    	
		Object result = productReadServiceWechat.listWeekMenu(bo);
    	return result;
    }
	
	
	/**
	 * 详情
	 * @param bo
	 * @return
	 * @throws WpsException
	 */
	@ResponseBody
	@RequestMapping("/detail")
    public Object detail(@RequestBody DetailProductBo bo) throws WpsException {
		
		Object result = productReadService.detail(bo);
		return result;
    }
	
	/**
	 * 列表
	 * @param bo
	 * @return
	 * @throws WpsException
	 */
	@ResponseBody
    @RequestMapping("/list")
    public Object list(@RequestBody SearchProductBo bo) throws WpsException {
		
		Object result = productReadService.list(bo);
		return result;
    }
	
}
